package edu.nf.ch03.controller;

import edu.nf.ch03.service.RagChatService;
import edu.nf.ch03.service.SseChatService;
import edu.nf.ch03.service.ToolChatService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;

/**
 * @author wangl
 * @date 2025/4/19
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/ai")
public class ChatController {

    private final SseChatService chatService;

    private final ToolChatService toolChatService;

    private final RagChatService ragChatService;

    @GetMapping("/chat")
    public SseEmitter chat(@RequestParam("prompt") String prompt) {
        return chatService.chat(prompt);
    }

    @GetMapping("/topic")
    public String topic(@RequestParam("prompt") String prompt) {
        return toolChatService.chat(prompt);
    }

    @GetMapping("/rag")
    public String rag(@RequestParam("prompt") String prompt) {
        return ragChatService.chat(prompt);
    }
}